import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { User } from '../users/users.entity';
import { Feed } from '../feeds/feed.entity';

@Entity('likes')
export class Like {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ name: 'liker_user_id' })
  likerUserId: number;

  @Column({ name: 'liked_user_id', nullable: true })
  likedUserId: number;

  @Column({ name: 'post_id', nullable: true })
  postId: number;

  @CreateDateColumn({ name: 'liked_at' })
  likedAt: Date;

  @Column({ default: 'active' })
  status: string;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'liker_user_id' })
  likerUser: User;

  @ManyToOne(() => User)
  @JoinColumn({ name: 'liked_user_id' })
  likedUser: User;

  @ManyToOne(() => Feed, feed => feed.comments, { nullable: true })
  @JoinColumn({ name: 'post_id' })
  post: Feed;
}